cmake_minimum_required(VERSION 3.14)
project(Camera_Loopback)

set(CMAKE_CXX_STANDARD 14)

set(LOOPBACK_LIB_NAME loopback)

add_library(${LOOPBACK_LIB_NAME} SHARED src/loopback.cpp)
add_executable(test src/test.cpp src/loopback.cpp)

# Thread
FIND_PACKAGE(Threads)
TARGET_LINK_LIBRARIES(${LOOPBACK_LIB_NAME} ${CMAKE_THREAD_LIBS_INIT})
TARGET_LINK_LIBRARIES(test ${CMAKE_THREAD_LIBS_INIT})

# Opencv
find_package(OpenCV REQUIRED)
target_link_libraries(${LOOPBACK_LIB_NAME} ${OpenCV_LIBS})
target_link_libraries(test ${OpenCV_LIBS})

# Self include
target_include_directories(${LOOPBACK_LIB_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_include_directories(test PUBLIC ${CMAKE_SOURCE_DIR}/include)
set_target_properties(${LOOPBACK_LIB_NAME} PROPERTIES PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/include/loopback.h)

# Installation
install(TARGETS ${LOOPBACK_LIB_NAME}
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib
        RUNTIME DESTINATION bin
        PUBLIC_HEADER DESTINATION include
        )